#include <REGX52.H>

void Delay(unsigned int xms)		//@12.000MHz
{
	unsigned char i, j;
	while(xms--)
	{
		i = 16;
		j = 147;
		do
		{
			while (--j);
		}
		while (--i);
	}
}




void SMG(unsigned int which,Number)
{
		switch(which)
		{
			case 1:P2_4=1,P2_3=1,P2_2=1;break;
			case 2:P2_4=1,P2_3=1,P2_2=0;break;
			case 3:P2_4=1,P2_3=0,P2_2=1;break;
			case 4:P2_4=1,P2_3=0,P2_2=0;break;
			case 5:P2_4=0,P2_3=1,P2_2=1;break;
			case 6:P2_4=0,P2_3=1,P2_2=0;break;
			case 7:P2_4=0,P2_3=0,P2_2=1;break;
			case 8:P2_4=0,P2_3=0,P2_2=0;break;
		}
		switch(Number)
		{
			case 0: P0=0x3F;break;
			case 1:P0=0x06;break;
			case 2:P0=0x5B;break;
			case 3:P0=0x4F;break;
			case 4:P0=0x66;break;
			case 5:P0=0x6D;break;
			case 6:P0=0x7D;break;
			case 7:P0=0X07;break;
			case 8:P0=0X7F;break;
			case 9:P0=0X6F;break;
		}
		Delay(1);
		P0=0x00;
		
}

void main()
{
	while(1)
	{
		SMG(1,5);
		SMG(2,2);
		SMG(3,0);
		
	}
 
}